//字符序列
#include <iostream>
using namespace std;
const int MAXN=12;
int n;
int a[MAXN+1];
int total;

void search(int k){
    if (k>n) return;
    for(int c=1;c<=3;c++){
        a[k]=c;
        if ((k>=4)&&(a[k]==a[k-2])&&(a[k-1]==a[k-3])) continue;
        if (k==n) total++;
        else search(k+1);
    }
}
int main(){
    cin>>n;
    search(1);
    cout<<total;
}